Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

180
Vistas
Displaying weekly calendar by clicking a button > in React.tsx

I am trying to create a weekly calendar, so something like Fri, Feb 04 - Thu, Feb 10 which will be dynamic. The first Issue I am trying to solve is to instead of having Fri, Feb 04 - Thu, Feb 10, I want this to be Sun, Jan 30 - Sat, Feb 5 for the entire week, not matter if we are on Friday, it should be displaying that range of dates for the week, and once we reach a new Sunday, then calculate the next range of dates.

const today = new Date().toString();
const endOfWeek = new Date(Date.now() + 6 * 24 * 60 * 60 * 1000).toString();

This is what helps me calculate the end of the week date, I make it into an array by using .split() and then I am able to manipulate the rest of the info but, since it depends on what today's date is and adding 6 days to it, that's why it never stays as Sunday-Saturday.

The second thing I am trying to figure out is to be able to calculate the next week. For example, assuming that I got the Sun-Sat dates to work, how would I go about calculating Sun, Feb 6 - Sat, Feb 12, Sun, Feb 13 - Sat, Feb 19 and so on by just clicking a button that will look like this symbol >, or calculate the previous weeks by clicking <.

I will greatly appreciate if someone can help me figure out how to stay at a static Sun-Sat date instead of Fri-Thu like for example today that is Friday. And I would also appreciate if someone could give me an idea on how to calculate the next week Sun-Sat dates. Thanks in advance!

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda